/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class ctlr_RenewSectionOnCompanyClass_Test {

    static testMethod void myUnitTest() 
    {
        // TO DO: implement unit test
        string result = null;
    	PageReference pageRef = null;
    	List<String> resultList = null;
    	ApexPages.StandardController accountExtendedObject = null;
    	ctlr_RenewSectionOnCompanyClass renewSectionClass = null;
        //For Positive Cases....
        
        //For Location Object Records...
        Location__c locationObject2 = new Location__c();
        locationObject2.Name = 'Test Land';
        locationObject2.Location_Type__c = 'Land';
        locationObject2.Rental_Rate__c = 18000;
        insert locationObject2;
        
        //Account Object Record...
        Account accountObject = new Account();
        accountObject.Name = 'Test Account';
        accountObject.License_Application_Step__c = 'Archived';
        accountObject.License_Application_Type__c = 'New License';
    	accountObject.Activity__c = 'Trading - One Activity';
    	accountObject.License_Issue_Date__c = system.today();
    	accountObject.License_Expiry_Date__c = System.Today().addYears(1);
    	insert accountObject;
    	
    	
    	//For Tenancy Object Records...
    	RecordType recordType = [select Id,IsActive,SObjectType,DeveloperName from RecordType where DeveloperName = 'New_Tenancy_Contract' AND SObjectType = 'Tenancy_Contract__c'];
    	Tenancy_Contract__c tenancyObject = new Tenancy_Contract__c();
    	tenancyObject.Location__c = locationObject2.id;
    	tenancyObject.RecordTypeId = recordType.id;
    	tenancyObject.Tenant__c = accountObject.id;
    	tenancyObject.Tenancy_Contract_Start_Date__c = accountObject.License_Issue_Date__c;
    	tenancyObject.Tenancy_Contract_Expiry_Date__c = date.TODAY().addyears(1).adddays(-1);
    	insert tenancyObject;
    	
    	//For Update the Location with the current Locaiton...
    	locationObject2.Current_Tenancy_Contract__c = tenancyObject.Id;
    	update locationObject2;
        
        //Change the Current Page id to Account Id...
    	ApexPages.CurrentPage().getParameters().put('id',accountObject.id);
    	
        //For ctlr_RenewSectionOnCompanyClass Class Test Coverage...
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	System.debug('The License Application Step = > '+ accountObject.License_Application_Step__c);
    	pageRef = renewSectionClass.renewAccountMethod();
    	
    	//Change the status to the Archived again for the Account Object...
    	accountObject.License_Application_Step__c = 'Archived';
    	update accountObject;
    	
    	
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	//Change the Current Page id to Account Id...
    	ApexPages.CurrentPage().getParameters().put('id',accountObject.id);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	renewSectionClass.tenancyIdforRenewalProperty = tenancyObject.Id;
    	pageRef = renewSectionClass.renewTenancyContractMethod();
    	
    	
    	//For Negative Test Case for Renew Section Class...
    	
    	//Change the status to the Archived again for the Account Object...
    	accountObject.License_Application_Step__c = 'Archived';
    	update accountObject;
    	
    	//Update the Tenancy Contract...
    	tenancyObject.Tenancy_Contract_Expiry_Date__c = date.TODAY().addyears(1).adddays(-40);
    	update tenancyObject;
    	
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	System.debug('The License Application Step = > '+ accountObject.License_Application_Step__c);
    	pageRef = renewSectionClass.renewAccountMethod();
    	
    	
    	//Change the status to the Archived again for the Account Object...
    	accountObject.License_Application_Step__c = 'Archived';
    	update accountObject;
    	
    	//For 1 Case...
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	renewSectionClass.tenancyIdforRenewalProperty = tenancyObject.Id;
    	pageRef = renewSectionClass.renewTenancyContractMethod();
    	
    	//For 2 Case...
    	//Change the status to the Archived again for the Account Object...
    	accountObject.License_Application_Step__c = 'Archived';
    	update accountObject;
    	
    	//For Location Not Associated Case...
    	locationObject2.Current_Tenancy_Contract__c = null;
    	update locationObject2;
    	
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	renewSectionClass.tenancyIdforRenewalProperty = tenancyObject.Id;
    	pageRef = renewSectionClass.renewTenancyContractMethod();
    	pageRef = renewSectionClass.renewAccountMethod();
    	
    	//For Renew Account Methods...
    	tenancyObject.RecordTypeId = recordType.Id;
    	update tenancyObject;
    	
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	pageRef = renewSectionClass.renewAccountMethod();
    	
    	
    	//For 3 Case...
    	//Suspension Record Associated Case....
    	//For Suspension Object Records...
		Fines__c fineObject = new Fines__c();
		fineObject.Issue_Date__c = System.today();
		fineObject.Account__c = accountObject.id;
		fineObject.Fine_Type__c = 'Fix Amount';
		fineObject.Fine_Amount__c = 1000;
		fineObject.Fines_Included__c = true;
		fineObject.Status__c = 'Suspended';
		insert fineObject;
    	
    	locationObject2.Current_Tenancy_Contract__c = tenancyObject.Id;
    	update locationObject2;
    	
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	renewSectionClass.tenancyIdforRenewalProperty = tenancyObject.Id;
    	pageRef = renewSectionClass.renewTenancyContractMethod();
    	pageRef = renewSectionClass.renewAccountMethod();
    	
    	//For 4 Case...
    	//Change the status to the Not Archived For Negative Test Case...
    	delete fineObject;
    	accountObject.License_Application_Step__c = '24324';
    	update accountObject;
    	
    	accountExtendedObject = new ApexPages.StandardController(accountObject);
    	renewSectionClass = new ctlr_RenewSectionOnCompanyClass(accountExtendedObject);
    	renewSectionClass.tenancyIdforRenewalProperty = tenancyObject.Id;
    	pageRef = renewSectionClass.renewTenancyContractMethod();
    	pageRef = renewSectionClass.renewAccountMethod();
    	
    	
    }
}